Skip to content

Fix macOS build: std::jthread is unavailable on libc++#32

Merged
audexdev merged 6 commits into
mainfrom
fix/macos-thread-portability
Jun 4, 2026
Merged

Fix macOS build: std::jthread is unavailable on libc++#32
audexdev merged 6 commits into
mainfrom
fix/macos-thread-portability

Conversation

@audexdev

@audexdev audexdev commented Jun 4, 2026

Copy link
Copy Markdown
Owner

Problem

CI fails on macos-latest (Debug tests + Release build) with:

error: no member named 'jthread' in namespace 'std'
  src/codec/lac/decoder.cpp:248
  src/codec/lac/encoder.cpp:392

std::jthread (C++20) is not exposed by the libc++ shipped on the current macos-latest image, while Linux (libstdc++) provides it — so Ubuntu and ASan/UBSan jobs pass and only macOS breaks. This is pre-existing on main (a docs-only PR surfaced it) and unrelated to that doc change.

Fix

  • Switch the encoder and decoder worker pools from std::jthread to std::thread (the only two std::jthread uses; main.cpp already uses std::thread).
  • Add an RAII WorkerJoinGuard that joins every started worker on scope exit, so a partial launch that throws during thread construction cannot leave joinable threads and call std::terminate. This preserves the exception-safe shutdown std::jthread gave for free and addresses the startup-safety concern in Make multithreaded encoder startup exception-safe #5.

Verification

Built and tested locally on macOS (the failing platform):

  • cmake --build succeeds, no jthread references remain
  • ctest: 2/2 suites pass
  • lac_cli selftest: all sample-rate/bit-depth round-trips pass

Closes #5

audexdev and others added 6 commits June 4, 2026 23:08
std::jthread is not provided by the libc++ shipped on macos-latest, so the
encoder and decoder failed to build there while Linux (libstdc++) passed.
Switch both worker pools to std::thread for portability and consistency with
the CLI decoder, and add a scope guard that joins every started worker even
if thread construction throws mid-startup, preserving the exception-safe
shutdown that std::jthread provided.

Closes #5

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@audexdev audexdev merged commit 21f5707 into main Jun 4, 2026
8 checks passed
@audexdev audexdev deleted the fix/macos-thread-portability branch June 4, 2026 17:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make multithreaded encoder startup exception-safe

1 participant